package utility

import (
	"crypto/md5"
	"encoding/json"
	"errors"
	"strings"
	"fmt"
)

func JsonToMap (jsonStr string) (map[string]interface{},error){
	var data map[string]interface{}
	if err := json.Unmarshal([]byte(jsonStr), &data); err != nil {
		return data,errors.New("解析失败")
	}

	return data,nil

}


func Md5(str string ) string {
	data := []byte(str)
	md5str := fmt.Sprintf("%x", md5.Sum(data))
	return md5str
}


func MapToArray(post map[string][]string) map[string]string {
	data := map[string]string{}
	for field,val := range post {
		data[field] = strings.Join(val, "")
	}
	return data
}